feat(telemetry): add telemetry support for user agent parsing#90
feat(telemetry): add telemetry support for user agent parsing#90BenjaminAbt wants to merge 10 commits intomainfrom
Conversation
gfoidl
left a comment
There was a problem hiding this comment.
Instead of the event source, I'd prefer to use OTel metrics via the meters.
Especially as we don't write to the event stream (which could be read e.g. via PerfView), and I don't think we need the diagnostic events.
| internal void UserAgentPresent() | ||
| { | ||
| if (!IsEnabled()) return; | ||
| _userAgentPresent?.Increment(); |
There was a problem hiding this comment.
As we don't write an event, should we use metrics (via meter factory) instead?
I'd prefer the OTel metrics here.
There was a problem hiding this comment.
There are too many projects that do not use OTEL - even I/we currently still use native app insights in almost all projects because OTEL features are missing.
There was a problem hiding this comment.
Hm, with UseAzureMonitor I see metrics in Azure. What features are there missing?
There was a problem hiding this comment.
But we would still enforce everybody to use OTEL as foundation... I am not happy with that.
|
@gfoidl , I added a telemetry hub and exposed otel native meters and dotnet metrics. |
gfoidl
left a comment
There was a problem hiding this comment.
For the OTel attributes we should follow the semantic convention (now, because changing it later would be a breaking change).
Sorry for the delay.
src/HttpUserAgentParser.AspNetCore/Telemetry/HttpUserAgentParserAspNetCoreMeters.cs
Outdated
Show resolved
Hide resolved
src/HttpUserAgentParser.AspNetCore/Telemetry/HttpUserAgentParserAspNetCoreMeters.cs
Outdated
Show resolved
Hide resolved
|
@gfoidl no problem. I expected the delay, since it was the holidays. Happy New Year. |
|
@gfoidl there is this note
does this really make sense? We have |
Makes sense, but the value has to be given as floating point number. Then the tools to display should show it as |
| - `useragent-present` (counter) | ||
| - `useragent-missing` (counter) |
There was a problem hiding this comment.
| - `useragent-present` (counter) | |
| - `useragent-missing` (counter) | |
| - `user_agent.present` (counter) | |
| - `user_agent.missing` (counter) |
| s_meter = meter ?? new Meter(MeterName); | ||
|
|
||
| s_cacheHit = s_meter.CreateCounter<long>( | ||
| name: "cache.hit", |
There was a problem hiding this comment.
| name: "cache.hit", | |
| name: "user_agent_parser.cache.hit", |
?
Otherwise it's only "cache" and which one is meant in a typical app with several caches.
| description: "MemoryCache cache hit"); | ||
|
|
||
| s_cacheMiss = s_meter.CreateCounter<long>( | ||
| name: "cache.miss", |
There was a problem hiding this comment.
| name: "cache.miss", | |
| name: "user_agent_parser.cache.miss", |
| description: "MemoryCache cache miss"); | ||
|
|
||
| s_cacheSize = s_meter.CreateObservableGauge<long>( | ||
| name: "cache.size", |
There was a problem hiding this comment.
| name: "cache.size", | |
| name: "user_agent_parser.cache.size", |
| - `cache-hit` (counter) | ||
| - `cache-miss` (counter) | ||
| - `cache-size` (observable gauge) |
There was a problem hiding this comment.
| - `cache-hit` (counter) | |
| - `cache-miss` (counter) | |
| - `cache-size` (observable gauge) | |
| - `user_agent_parser.cache.hit` (counter) | |
| - `user_agent_parser.cache.miss` (counter) | |
| - `user_agent_parser.cache.size` (observable gauge) |
| /// counter reports a correct value once a listener attaches. | ||
| /// </remarks> | ||
| [NonEvent] | ||
| internal static void ConcurrentCacheSizeSet(int size) => HttpUserAgentParserTelemetryState.SetConcurrentCacheSize(size); |
There was a problem hiding this comment.
| internal static void ConcurrentCacheSizeSet(int size) => HttpUserAgentParserTelemetryState.SetConcurrentCacheSize(size); | |
| internal static void CacheSizeSet(int size) => HttpUserAgentParserTelemetryState.SetConcurrentCacheSize(size); |
| .AddHttpUserAgentParser(); | ||
| ``` | ||
|
|
||
| ### ConcurrentDictionary cache |
There was a problem hiding this comment.
| ### ConcurrentDictionary cache | |
| ### Cached parser |
?
The CDN and even concurrent shouldn't be exposed, as they're details.
| - `cache-concurrentdictionary-hit` (incrementing) | ||
| - `cache-concurrentdictionary-miss` (incrementing) | ||
| - `cache-concurrentdictionary-size` (polling) |
There was a problem hiding this comment.
| - `cache-concurrentdictionary-hit` (incrementing) | |
| - `cache-concurrentdictionary-miss` (incrementing) | |
| - `cache-concurrentdictionary-size` (polling) | |
| - `cache-hit` (incrementing) | |
| - `cache-miss` (incrementing) | |
| - `cache-size` (polling) |
| - `parse-requests` (counter) | ||
| - `parse-duration` (histogram, ms) | ||
| - `cache-concurrentdictionary-hit` (counter) | ||
| - `cache-concurrentdictionary-miss` (counter) | ||
| - `cache-concurrentdictionary-size` (observable gauge) |
There was a problem hiding this comment.
Please update to current used names.
|
|
||
| Core (`MyCSharp.HttpUserAgentParser`) | ||
|
|
||
| - `parse-requests` |
Uh oh!
There was an error while loading. Please reload this page.